﻿using System;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;

partial class BookmarkProcessor
{

  static void Main(string[] args)
  {
    var rootDir = Directory.GetCurrentDirectory();
    if (Debugger.IsAttached)
    {
      rootDir = @"D:\verysync";
    }
    var bat = Path.Combine(rootDir, "ffmpeg_pbf_extract.bat");

    // 执行处理流程
    var pbfFiles = Directory.GetFiles(rootDir, "*.pbf", SearchOption.AllDirectories).ToList();
    PbfBookmarkList pbflist = new PbfBookmarkList(pbfFiles);
    Console.WriteLine(pbflist);

    string pbfcmd = pbflist.ToCmdList();
    //Console.WriteLine(pbfcmd);
    File.WriteAllText(bat, pbfcmd, Encoding.GetEncoding("gb2312"));
    //OpenFileWithDefaultProgram(bat);
  }

  public static void OpenFileWithDefaultProgram(string filePath)
  {
    try
    {
      // 检查文件是否存在
      if (!File.Exists(filePath))
      {
        Console.WriteLine("文件不存在！");
        return;
      }

      // 使用默认程序打开文件
      Process.Start(new ProcessStartInfo(filePath)
      {
        UseShellExecute = true // 确保使用系统的Shell执行（默认关联程序）
      });
    }
    catch (Win32Exception ex)
    {
      Console.WriteLine($"没有找到关联程序: {ex.Message}");
    }
    catch (Exception ex)
    {
      Console.WriteLine($"错误: {ex.Message}");
    }
  }

}
